package cn.sdhuijin.healthexam.activity;

import java.io.File;
import java.io.FileNotFoundException;
import java.io.FileReader;
import java.io.IOException;
import java.util.Properties;

import android.content.Intent;
import android.os.Bundle;
import android.os.Environment;
import android.view.View;
import android.view.View.OnClickListener;
import cn.sdhuijin.healthexam.ExitApplication;
import cn.sdhuijin.healthexam.R;
import cn.sdhuijin.healthexam.control.AbstractControlActivity;

public class DiabetesInfoActivity extends AbstractControlActivity implements
		OnClickListener {

	@Override
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		setContentView(R.layout.activity_diabetes_info);
		ExitApplication.getInstance().addActivity(this);

		Intent intent = getIntent();
		// 获取传递过来的sql语句
		String fileName = intent.getStringExtra("filename");

		addTextView(R.id.txt_diabetes_name, "姓名");
		addTextView(R.id.txt_card_id, "身份证号");
		addTextView(R.id.txt_diabetes_date, "随访日期");
		addTextView(R.id.txt_diabetes_way, "随访方式_content");
		addTextView(R.id.txt_blood_pressure, "高压");
		addTextView(R.id.txt_blood_pressure_low, "低压");
		addTextView(R.id.txt_weight, "体重");
		addTextView(R.id.txt_mass_index, "体质指数");
		addTextView(R.id.txt_pulse, "足背动脉搏动_content");
		addTextView(R.id.txt_other, "体征其他");
		addTextView(R.id.txt_symptoms, "症状_content");
		addTextView(R.id.txt_symptom_other, "症状其他");
		addTextView(R.id.txt_smoke, "日吸烟量");
		addTextView(R.id.txt_drink, "日饮酒量");
		addTextView(R.id.txt_sports_week, "运动次数");
		addTextView(R.id.txt_sports_minute, "运动时间");
		addTextView(R.id.txt_staples, "主食");
		addTextView(R.id.txt_emotional_adjust, "心理调整_content");
		addTextView(R.id.txt_medical_behavior, "遵医行为_content");
		addTextView(R.id.txt_compliance, "服药依从性_content");
		addTextView(R.id.txt_drug_reactions, "药物不良反应_content");
		addTextView(R.id.txt_reactive_hypoglycemia, "低血糖反应_content");
		addTextView(R.id.txt_fasting_blood_sugar, "空腹血糖值");
		addTextView(R.id.txt_visit_classification, "此次随访分类_content");
		addTextView(R.id.txt_glycosylated_hemoglobin, "糖化血红蛋白");
		addTextView(R.id.edt_glycosylated_hemoglobin_date, "糖化血红蛋白检查日期");
		addTextView(R.id.txt_drug_name_first, "药物名称一");
		addTextView(R.id.txt_drug_num_first, "药物一次数");
		addTextView(R.id.txt_drug_amount_first, "药物一用量");
		addTextView(R.id.txt_drug_name_second, "药物名称二");
		addTextView(R.id.txt_drug_num_second, "药物二次数");
		addTextView(R.id.txt_drug_amount_second, "药物二用量");
		addTextView(R.id.txt_drug_name_third, "药物名称三");
		addTextView(R.id.txt_drug_num_third, "药物三次数");
		addTextView(R.id.txt_drug_amount_third, "药物三用量");

		addTextView(R.id.txt_insulin_kind, "胰岛素种类");
		addTextView(R.id.txt_insulin_use, "胰岛素用法和用量");
		addTextView(R.id.txt_referral_reason, "转诊原因");
		addTextView(R.id.txt_referral_place, "转诊机构及科别");
		addTextView(R.id.txt_next_date, "下次随访日期");
		addTextView(R.id.txt_visit_doctor, "随访医生签名");

		setButtonListener(this, R.id.btn_back);

		Properties prop = new Properties();
		try {
			File f = new File(Environment.getExternalStorageDirectory()
					.getPath() + "/health/" + fileName + ".txt");
			if (f.exists()) {

				controlManager.setPropertiesPath(f.getAbsolutePath());
				controlManager.toControl();

				prop.load(new FileReader(f.getAbsolutePath()));
			} else {
				this.toastInformation(R.string.record_deleted);
			}
		} catch (FileNotFoundException e) {
			e.printStackTrace();
		} catch (IOException e) {
			e.printStackTrace();
		}
	}

	@Override
	public void onClick(View v) {
		int clickId = (Integer) v.getId();
		switch (clickId) {
		case R.id.btn_back:
			finish();
			break;
		default:
			break;
		}

	}

}
